//
// core - server core source code.
//
// $Rev$
// $Author$
// $Date$
//
// Define class LoopThread.
//

#include "core/loop_thread.h"

#include <boost/bind.hpp>

#include "core/base/logging.h"

namespace core {

LoopThread::LoopThread(BaseLoop *loop, const std::string &name, bool joinable)
       : loop_(loop),
         thread_(name, boost::bind(&LoopThread::Loop, this), joinable) {}

LoopThread::~LoopThread() {}

void LoopThread::StartLoop() {
  this->thread_.Start();
}

void LoopThread::StopLoop(bool force_quit) {
  if(force_quit) this->GetLoop()->Quit();
  this->loop_->Wakeup();
  this->thread_.Join();
}

}  // namespace core

